<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>比赛成绩的查看页面</title>
    <link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script src="../../res/js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../res/layui/layui.js"></script>
    <script src="../../res/js/Tools.js"></script>
</head>
<body>
<form class="layui-form" action="" id="Leader">
    <input type="hidden" name="resultId" id="resultIds"/>
    <div class="layui-form-item"></div>
    <div class="layui-form-item">
        <label class="layui-form-label">运动员名称</label>
        <div class="layui-input-inline">
            <select name="athleteName" id="athleteNames" lay-verify="required" lay-filter="culture">
                <option value="" selected=""></option>
            </select>
        </div>
        <label class="layui-form-label">比赛名称</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="matchName" id="matchNames" required
                   lay-verify="required" placeholder="比赛名称" autocomplete="off"/>
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">比赛时间</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="matchTime" id="matchTimes" placeholder="yyyy-MM-dd">
        </div>
        <label class="layui-form-label">比赛地点</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="matchAddr" id="matchAddrs" required
                   lay-verify="required" placeholder="比赛地点" autocomplete="off"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">比赛项目</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="matchItem" id="matchItems" required
                   lay-verify="required" placeholder="比赛成绩" autocomplete="off"/>
        </div>
        <label class="layui-form-label">比赛成绩</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="matchResult" id="matchResults" required
                   lay-verify="required" placeholder="比赛成绩" autocomplete="off"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">比赛排名</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="matchSort" id="matchSorts" required
                   lay-verify="required" placeholder="比赛排名" autocomplete="off"/>
        </div>
        <label class="layui-form-label">积分</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="score" id="scores" required
                   lay-verify="required" placeholder="积分" autocomplete="off"/>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        //日期渲染
        laydate.render({
            elem: '#matchTimes'
        });

        /**
         * 新增和修改
         */
        var form = null ;
        layui.use('form', function(){
            form = layui.form;
            //监听提交
            form.on('submit(formDemo)', function(data){

                var rolesId = "";
            });
            //运动员名称
            $.ajax({
                type:"POST",
                url:'../../UserseControllerAthleteResults/findByAthleteName',  //从数据库查询返回的是个list
                dataType: "json",
                contentType: false,
                async: false,
                cache: false,
                success: function (data) {
                    $.each(data,function(index,item){
                        /*$('#sprotNames').append(new Option(item.sportName, item.sportId));*///往下拉菜单里添加元素
                        //$('#athleteNames').append(new Option(item.athleteName));
                        $('#athleteNames' ). append("<option value='"+item.athleteId+"'>"+item.athleteName+"</option>") ;
                    })
                    form.render();//菜单渲染 把内容加载进去
                }
            })
            var id = getQueryString("id");
            if(id !="" && id != null){
                findlx(id);
            }
        });
        /**
         * 修改显示
         */
        function findlx(){
            var id = getQueryString("id");
            //alert(id);
            if(id){
                var url = "../../UserseControllerAthleteResults/selectByPrimaryKey";
                var data = {resultId:id};
                //jquery的ajax方法,查询类型的方法

                $.get(url,data,function(obj){
                    //从后台传过来的数据obj$("[value='11']").prop("checked",true);
                    //alert(obj.athleteId);
                    $("#resultIds").val(obj.resultId);
                    $("#athleteNames").val(obj.athleteId);
                    $("#matchNames").val(obj.matchName);
                    $("#matchTimes").val(obj.matchTime);
                    $("#matchAddrs").val(obj.matchAddr);
                    $("#matchItems").val(obj.matchItem);
                    $("#matchResults").val(obj.matchResult);
                    $("#matchSorts").val(obj.matchSort);
                    $("#scores").val(obj.score);
                    //重新渲染
                    form.render();
                },"json");
            }

        }
    });
</script>
</body>
</html>